#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e4 + 5;

int n, m, money;
int w[N], v[N];
int f[N], dp[N];
void init(int n) { rep(i, 1, n) f[i] = i; }
int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }
void merge(int x, int y) {
  int fx = find(x), fy = find(y);
  if (fx == fy) return;
  f[fy] = fx;
  w[fx] += w[fy];
  v[fx] += v[fy];
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> money;
  init(n);
  rep(i, 1, n) cin >> w[i] >> v[i];
  rep(i, 1, m) {
    int x, y;
    cin >> x >> y;
    merge(x, y);
  }
  rep(i, 1, n) {
    if (f[i] != i) continue;
    per(j, money, w[i]) dp[j] = max(dp[j - w[i]] + v[i], dp[j]);
  }
  cout << dp[money];
  return 0;
}